#include "../SystemEventMonitor.h"
#include "../TcpSocket.h"

#include <stdio.h>
#include <string.h>
#include <string>

using namespace Greatewall::Interface;
using namespace Greatewall::Network;

class TestTcpClient : public TcpSocket
{
public:
    TestTcpClient(SocketEventMonitor& monitor)
        : TcpSocket(monitor)
    {}

    virtual void
    handleInbound()
    {}

    virtual bool
    handleOutbound()
    { return true; }

private:
    unsigned _count;
};

int main(void)
{
    SystemEventMonitor system_event_monitor;
    
    TestTcpClient client(system_event_monitor);
    client.initTcpSock("127.0.0.1", 12999, "");

    //system_event_monitor.registerSocket(&client, SocketEventMonitor::INOUT);

    //system_event_monitor.run();
    char*       buf = 0;
    ssize_t     siz = 0;

    std::string str = "Hello!\0";
    siz = str.size();
    client.send(str.c_str(), siz);

    client.recv(buf, siz, false);

    printf("%s\n", buf);
}
